import { IsNumber, IsString } from 'class-validator'
import {
  Column,
  CreateDateColumn,
  Entity,
  JoinColumn,
  ManyToOne,
  PrimaryGeneratedColumn,
  UpdateDateColumn,
} from 'typeorm'
import { WheelPrize } from '../../wheel-prize/entities/wheel-prize.entity'

/** 抽奖记录 */
@Entity('wheel_record')
export class WheelRecord {
  @PrimaryGeneratedColumn()
  @IsNumber()
  wheelRecordId?: number

  /**
   * 用户UID
   */
  @Column()
  @IsString()
  userUid: string

  /**
   * 奖品ID
   */
  @Column()
  @IsString()
  wheelPrizeId: number

  @ManyToOne(() => WheelPrize, wheelPrize => wheelPrize.wheelPrizeId)
  @JoinColumn({ name: 'wheelPrizeId' })
  wheelPrize?: WheelPrize

  @CreateDateColumn()
  createdAt?: Date

  @UpdateDateColumn()
  updatedAt?: Date
}
